DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Databases > SQL Development

Discuss "date problem" in the SQL Development forum.

SQL Development - Structured Query Language (SQL) is the talk of databases. Discuss topics such as joins, triggers and other advanced SQL topics.


Reply « Previous Thread | Next Thread »  
 
LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old May 12th, 2008, 01:47 PM
Contributing Member

 
Join Date: Mar 2008
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
todd2006 is an unknown quantity at this point
Default date problem

Hi,

I have this sql code

Code:
str="SELECT * FROM Registration  where ExpirationDate < 
getdate() order by convert(smalldatetime,ExpirationDate) desc"
it gives me an error like

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.


ExpirationDate is a varchar field

todd
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old May 12th, 2008, 01:51 PM
mehere's Avatar
Super Mistress of Sarcasm

 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 111
Thanks: 8
Thanked 20 Times in 18 Posts
Rep Power: 1
mehere is on a distinguished road

Awards Showcase
Microsoft SQL Server Classic ASP 
Total Awards: 2

Default

you need to convert the field, like you did in your ORDER BY clause ... like so
Code:
str="SELECT * FROM Registration  where convert(smalldatetime,ExpirationDate) < 
getdate() order by convert(smalldatetime,ExpirationDate) desc"
why is it your date field is a varchar type and not a date type?

Comments on this post
jmurrayhead agrees: indeed
__________________
Quote of the Month:
Strife: As long as we have each other, we'll never run out of problems.

Questions to Ponder:
Should vegetarians eat animal crackers?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright © 2008 sbenj69
Reply With Quote
Reply

  DeveloperBarn Forums > Databases > SQL Development

Bookmarks

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display Assembly File Date And Time Wolffy .Net 0 April 9th, 2008 11:57 AM
Date Last Modified for ASP Pages mehere Classic ASP 0 March 21st, 2008 12:20 PM

LinkBacks (?)
LinkBack to this Thread: http://www.developerbarn.com/sql-development/180-date-problem.html
Posted By For Type Date
Team Wolfguard Solutions - Resources This thread Refback May 14th, 2008 03:11 PM


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 10:50 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46