Results 1 to 12 of 12

Thread: datetime

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2008
    Posts
    31

    datetime

    Hi

    I have a datetimepicker that displays only the date at design and runtime. However, in the datagirid it shows as date and time. I've had a troll round and it seems there's a lot of answers but nothing seems to work. I'd like to display only the date in the datagrid or just set the time to 00.00.

    Thanks for your help

  2. #2
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: datetime

    Is this for VB6, .NET or something else?

    For example (ASP.NET 2005)

    I use a calendar control (e.g called calDate), and i do this

    Code:
    calDate.SelectedDate.ToString("dd/MM/yyyy")
    which i pass back to the datagrid.
    ___________

    If its VB6 and your using the DateTimePicker Control then on the property page you can change the format (dropdown) to a short date.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2008
    Posts
    31

    Re: datetime

    Sorry, It's for VB.NET!

  4. #4
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Re: datetime

    DateTimePicker1.Value.Date

    Think that will give you just the date.

  5. #5
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: datetime

    Have you tried changing the format property?

    If yes, then you might have to check whats being passed to the datagrid.

    See image for example.
    Attached Images Attached Images  

  6. #6
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Re: datetime

    Me.DateTimePicker1.Value.Date.ToShortDateString

    Sorry that will work.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2008
    Posts
    31

    Re: datetime

    Yes, I've tried Format and CustomFormat

    The app accepts the code:

    "Me.DateDateTimePicker.Value.Date.ToShortDateString"

    but when I run the app the datagrid column still returns dd/mm/yyyy, hh/mm

    The app is for an angling club to record catch and release tags for conservation purposes and the time in the date column wouldn't make any sense to the user but the date is very important.

    dd/mm/yyyy 00/00 would be understandable

  8. #8
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: datetime

    have you checked to see whats been passed to the datagrid?? (So that you know its the DateTimePicker that is passing this format : dd/mm/yyyy, hh/mm) just in case the gridview is doing something with it, and the problem lies there.

  9. #9
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Re: datetime

    Good call, lets work out wots actually going wrong. Stick a break point on the code that passes the date to the GridView and see if its the correct format!

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Apr 2008
    Posts
    31

    Re: datetime

    Where will I find the code? I cant find any events with formatting code

  11. #11
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Re: datetime

    Post your code that inserts the data to the datagrid.

  12. #12
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: datetime

    Whenever you bind data to a datagrid, you should be able to see whats being passed into each row by looking in something like the RowDataBound Event for the DataGrid...

    ps. (I'm currently using ASP.NET so my knowledge is based around that)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width