Current location: Hot Scripts Forums » Programming Languages » ASP » Inserting correct date format into a sql string


Inserting correct date format into a sql string

Reply
  #1 (permalink)  
Old 12-03-06, 06:43 PM
Iudex Iudex is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Inserting correct date format into a sql string

How can I format the todays date to fit into a SQL date field? The format is 0000-00-00 00:00:00

Another question: When the field is filled out, can I then write only the date and not the time on my website without using for example left(date,11)?

Last edited by Iudex; 12-03-06 at 07:19 PM.
Reply With Quote
  #2 (permalink)  
Old 12-03-06, 08:57 PM
koncept
Guest
 
Posts: n/a
i have found that using now() works if you want to code it using asp and the database accepts more than one format but displays it in only one it seems.

if you only want to store the date, there should be a date format (i might be mixing it up with one of the other dbases i work with) but try CDate()
Reply With Quote
  #3 (permalink)  
Old 12-04-06, 01:52 AM
Iudex Iudex is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Yes! NOW() worked nicely!

And I found out my second question;
SELECT DATE_FORMAT(columnName,'%d/%m/%Y') FROM tableName

Now I can store both date and time(just in case), and still filter out what I want as output.

Google for sure is my friend...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
date format mysql and php Deansatch PHP 9 03-28-08 04:06 AM
Urgent converting String to Date yymae Everything Java 1 01-16-04 11:22 AM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM
change my field in this example sal21 ASP 3 07-14-03 02:49 AM


All times are GMT -5. The time now is 03:54 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.