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
 WeekDay as Number

Author  Topic 

kris55
Starting Member

6 Posts

Posted - 2007-04-18 : 19:28:46

Hello Folks,

I am new to this forum and very excited to see this. I have a question in asp.net can any body help me

I have a date field suppose 4/18/2007. I want to get the Number from this date

Lets say

Monday - 1
Tuesday - 2
Wednesday -3
Thursday - 4
Friday - 5
Saturday - 6
Sunday - 7



the above date is Wednesday so i want to get the number "3"

Is it possible..? appreciate your help guys
I am using VB.NET/ASP.NET
Thanks
Kris

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-18 : 19:43:02
[code]
select datepart(weekday, '20070418')
[/code]


KH

Go to Top of Page

cvraghu
Posting Yak Master

187 Posts

Posted - 2007-04-18 : 19:46:54
Please read the help for DateTime.DayOfWeek in MSDN.

DateTime dt = new DateTime(2003, 5, 1);
Console.WriteLine(dt.DayOfWeek);
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-04-19 : 00:30:04
note that datepart is 1-based but DateTime.DayOfWeek is 0-based.

1-based enums/collections are so annoying!!


www.elsasoft.org
Go to Top of Page

kris55
Starting Member

6 Posts

Posted - 2007-04-19 : 12:10:22
quote:
Originally posted by khtan


select datepart(weekday, '20070418')



KH





Thx guys appreciate your help
Go to Top of Page
   

- Advertisement -