russomr
asked on
Display date with ToShortDateString()
I have a datetime field in SQL Server that is being pulled into the datareader. I'm trying to display it like so:
lblEstCompletionDate.Text = dr["EstCompletionDate"].To ShortDateS tring();
I'm trying all kinds of things and just can't get it to display in a mm/dd/yyyy format. I'm not sure why the above does not work. I'm getting:
'object' does not contain a definition for 'ToShortDateString'
What is the propper way to accomplish what I'm trying? If it's not ToShortDateString, what is it?
Thanks in advance.
lblEstCompletionDate.Text = dr["EstCompletionDate"].To
I'm trying all kinds of things and just can't get it to display in a mm/dd/yyyy format. I'm not sure why the above does not work. I'm getting:
'object' does not contain a definition for 'ToShortDateString'
What is the propper way to accomplish what I'm trying? If it's not ToShortDateString, what is it?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Arthur_Wood,
> or try this:
>
> lblEstCompletionDate.Text = cDate(dr["EstCompletionDat e"]).ToStr ing(<wbr/> "mm/dd/yyy <wbr/>y'")
>
> AW
by the syntax used in the question, I would assume russomr uses C# not VB so the cDate function wouldn't work.
Besides, russomr you can use ToString method to output a certain date format, but then you should use ToString("MM/dd/yyyy") as if you use lowercase m that will output minutes not month.
> or try this:
>
> lblEstCompletionDate.Text = cDate(dr["EstCompletionDat
>
> AW
by the syntax used in the question, I would assume russomr uses C# not VB so the cDate function wouldn't work.
Besides, russomr you can use ToString method to output a certain date format, but then you should use ToString("MM/dd/yyyy") as if you use lowercase m that will output minutes not month.
lblEstCompletionDate.Text = cDate(dr["EstCompletionDat
AW