-
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
-
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.
-
Re: datetime
-
Re: datetime
DateTimePicker1.Value.Date
Think that will give you just the date.
-
1 Attachment(s)
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.
-
Re: datetime
Me.DateTimePicker1.Value.Date.ToShortDateString
Sorry that will work.
-
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
-
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.
-
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!
-
Re: datetime
Where will I find the code? I cant find any events with formatting code
-
Re: datetime
Post your code that inserts the data to the datagrid.
-
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)