2/10/2004 2:17:16 PM
I would like to be able to break this value up. Is there a function that
allows me to pull whatever I want out of this?
For example, if I just want the year 2004 pulled out (for a drop down
list I'm creating) what would the function be to do that?
And If I just want the day, 10 pulled out, then how would I do that?
part of the problem is that depending on the month, is the number of
digits one counts from the front. 10,11,12 add one digit to the front of
the string, making this difficult.
I'm creating a search between dates so someone can select the day, month
and year as beginning value, and the end value. So how would I go about
disecting this string?
Thanks,
Bill
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Bill <williamzim2000@.yahoo.com> wrote in message news:<40295fcd$0$202$75868355@.news.frii.net>...
> I have a date that I get from my now() function that returns:
> 2/10/2004 2:17:16 PM
> I would like to be able to break this value up. Is there a function that
> allows me to pull whatever I want out of this?
> For example, if I just want the year 2004 pulled out (for a drop down
> list I'm creating) what would the function be to do that?
> And If I just want the day, 10 pulled out, then how would I do that?
> part of the problem is that depending on the month, is the number of
> digits one counts from the front. 10,11,12 add one digit to the front of
> the string, making this difficult.
> I'm creating a search between dates so someone can select the day, month
> and year as beginning value, and the end value. So how would I go about
> disecting this string?
> Thanks,
> Bill
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Via Book online (7.0 / 2000)
DATEPART ( datepart , date )
Arguments
datepart
Is the parameter that specifies the part of the date to return. The
table lists dateparts and abbreviations recognized by Microsoft SQL
Server.
Datepart Abbreviations
year yy, yyyy
quarter qq, q
month mm, m
dayofyear dy, y
day dd, d
week wk, ww
weekday dw
hour hh
minute mi, n
second ss, s
millisecond ms
Also be aware of the data in the table. If it includes time, you'll
want to accomodate for that in your between / ( >= <= ).|||Bill (williamzim2000@.yahoo.com) writes:
> I have a date that I get from my now() function that returns:
> 2/10/2004 2:17:16 PM
> I would like to be able to break this value up. Is there a function that
> allows me to pull whatever I want out of this?
In SQL Server there is datepart. On the other hand there is no Now()
function, so I suspect that you are in the wrong newsgroup. Hm, let's
see, Now() smells like Access but also Visual Basic. I think that there
is a datepart() function in VB too. Then again, whatever you are using
it's likely to come with online documentation, so check there.,
--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
没有评论:
发表评论