Reply
Old 06-18-2008, 12:49 AM separate date
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
hi all..

in my database, i have created date with format "15 June 2008"

how do i output it so i only take 15.. is it possible?

thanks
Nazi370 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 06-18-2008, 02:35 AM Re: separate date
chrishirst's Avatar
Super Moderator

Posts: 26,371
Location: Blackpool. UK
Trades: 0
What database?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | Crowded Nightclub? | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-18-2008, 02:55 AM Re: separate date
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
sql server 2000...

the format for the database is Varchar and not Date

Dim myDate As String = Trim(ddlStartDay.SelectedItem.Value) & " " & Trim(ddlStartMonth.SelectedItem.Value) & " " & Trim(ddlStartYear.SelectedItem.Value)

so in my database it will appear like '15 June 2008' and so on when retrieve it.
thanks
Nazi370 is offline
Reply With Quote
View Public Profile
 
Old 06-18-2008, 02:03 PM Re: separate date
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,674
Name: John Alexander
Trades: 0
Select DatePart(dd, Cast('15 June 2008' as varChar))
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-19-2008, 03:21 AM Re: separate date
chrishirst's Avatar
Super Moderator

Posts: 26,371
Location: Blackpool. UK
Trades: 0
It's much simpler when you store dates as dates not strings.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | Crowded Nightclub? | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-19-2008, 04:21 AM Re: separate date
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
since i have 3 dropdownlist boxes... it is much easier for user to select dd/month/year rather than typing it..


what if 15 June 2008 not specific?

Select DatePart(dd, Cast('unknown value' as varChar))
Nazi370 is offline
Reply With Quote
View Public Profile
 
Old 06-22-2008, 06:24 AM Re: separate date
chrishirst's Avatar
Super Moderator

Posts: 26,371
Location: Blackpool. UK
Trades: 0
Select DatePart(dd, Cast(ColumnName as varChar))

Quote:
since i have 3 dropdownlist boxes... it is much easier for user to select dd/month/year rather than typing it
Assuming you concatenate the three values into a single string on insert, it's just as easy to convert to a date at the same time.
AND if your column is already a date type the conversion should be done automatically by the server on inserting.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | Crowded Nightclub? | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to separate date
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10768 seconds with 13 queries