Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Date Format

Author  Topic 

vk18
Posting Yak Master

146 Posts

Posted - 2007-04-02 : 16:23:55
Hi Friends,

How to remove slash from the date field. I have like '2/20/2007' . I want in the format of 2202007. How can we do this. I am using VB.NET/ASP.NET and SqlServer2000 appreciate your help
Thx

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-04-02 : 16:31:13
Give a try

Format(CDate(strDate), "dddd MMM ddyyyy")
Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-04-02 : 16:33:18
Please check
I think, using this format, you can change in any style as you want

Regards
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-04-02 : 17:28:49
I think that should be

Format(CDate(DateTime.Now), "MMddyyyy")

Note, in your example you asked for 2/20/2007 to be formatted as 2202007, but the code I gave will give you 02202007 (the month will be zero padded), you should zero pad otherwise the values will be ambiguous, eg. is 1232007 12/3/2007 or 1/23/2007?

If you really don't want the zero padding use

Format(CDate(DateTime.Now), "Mddyyyy")
Go to Top of Page

vk18
Posting Yak Master

146 Posts

Posted - 2007-04-02 : 17:55:50
quote:
Originally posted by snSQL

I think that should be

Format(CDate(DateTime.Now), "MMddyyyy")

Note, in your example you asked for 2/20/2007 to be formatted as 2202007, but the code I gave will give you 02202007 (the month will be zero padded), you should zero pad otherwise the values will be ambiguous, eg. is 1232007 12/3/2007 or 1/23/2007?

If you really don't want the zero padding use

Hi,
I tried this one i am getting an error message stating that
"Over load resolution failed because no accessible format can be called wihtout a narrowing conversion".
Any Idea..?
Thx

Format(CDate(DateTime.Now), "Mddyyyy")


Go to Top of Page
   

- Advertisement -