Hello,
I have gone through some of the other solutions to similar problems posted here, but none seemed to work for me. So, as a last ditch effort I posting this in hopes someone can help. This is what I have.
SQL table
column terminateddate - varchar type with date stored as mm/dd/yyyy
On an ASP page I'm trying to put together a SELECT statement that compares two dates, the one in the table and a requested variable. Here is what I have so far...
SQL = "SELECT * FROM table where datediff(d,Conv ert(varchar(20) ,Convert(dateti me,terminatedda te), 101),""&request edvariable&"") < 30 ORDER by lastname"
However, no matter how I change it all I get is the same error (below).
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Am I doing something wrong, any help would be great. I have several other projects to get down and this is holding me up.
Thanks
2 10014 ck9663 2,878
Recognized Expert Specialist
Hello,
I have gone through some of the other solutions to similar problems posted here, but none seemed to work for me. So, as a last ditch effort I posting this in hopes someone can help. This is what I have.
SQL table
column terminateddate - varchar type with date stored as mm/dd/yyyy
On an ASP page I'm trying to put together a SELECT statement that compares two dates, the one in the table and a requested variable. Here is what I have so far...
SQL = "SELECT * FROM table where datediff(d,Conv ert(varchar(20) ,Convert(dateti me,terminatedda te), 101),""&request edvariable&"") < 30 ORDER by lastname"
However, no matter how I change it all I get is the same error (below).
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Am I doing something wrong, any help would be great. I have several other projects to get down and this is holding me up.
Thanks
either (or both) of your variable have an invalid date and take note of this from online help:
"DATEDIFF produces an error if the result is out of range for integer values. For milliseconds, the maximum number is 24 days, 20 hours, 31 minutes and 23.647 seconds. For seconds, the maximum number is 68 years."
Hello,
I have gone through some of the other solutions to similar problems posted here, but none seemed to work for me. So, as a last ditch effort I posting this in hopes someone can help. This is what I have.
SQL table
column terminateddate - varchar type with date stored as mm/dd/yyyy
On an ASP page I'm trying to put together a SELECT statement that compares two dates, the one in the table and a requested variable. Here is what I have so far...
SQL = "SELECT * FROM table where datediff(d,Conv ert(varchar(20) ,Convert(dateti me,terminatedda te), 101),""&request edvariable&"") < 30 ORDER by lastname"
However, no matter how I change it all I get is the same error (below).
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Am I doing something wrong, any help would be great. I have several other projects to get down and this is holding me up.
Thanks
Hey -
You may try this one -
SELECT * FROM table
-
where datediff(d, Convert(char(10),terminateddate, 121),CONVERT(char(10), " & requestedvariable &",121)) < 30 ORDER by lastname
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Lynn |
last post by:
On a form I have
Date_Start Date_End
I have a new
Date_Start1 Date_End1 which the use
inputs.
I need to validate that Date_Start1 and Date_End1 are a date range
entirely separate from Date_Start and Date_End i.e. no overlapping
|
by: Lauren Quantrell |
last post by:
I have a stored procedure using Convert where the exact same Convert
string works in the SELECT portion of the procedure but fails in the
WHERE portion.
The entire SP is listed below.
Specifically, I have a problem with this portion in the WHERE clause:
DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between
CONVERT(smalldatetime,str(DATEPART(Month, @DateNow)+1) + '/' +
str(DATEPART(Day, tblMyEventTableName.TaskDateTime)) + '/'...
|
by: Richard Hollenbeck |
last post by:
I'm trying to write some code that will convert any of the most popular
standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan
1908) and compare the first with the second and calculate days, months, and
years. This is not for a college course. It's for my own personal
genealogy website. I'm stumped about the code. I'm working on it but not
making much progress. Is there any free code available anywhere? I know it...
|
by: UBI |
last post by:
Vorrei suggerire una funzione completa per la differenza fra due date.
(questo è codice freeware, niente di illegale)
La funzione seguente permette il calcolo di una differenza precisa tra due
date/tempi
Si deve specificare come si vuole la differenza tra le due date/tempi
fornendo annno (y), mese (m), giorno (d), ora (h), minuto (n), secondo (s).
Esempio:
?Diff2Dates("y", #06/01/1998#, #06/26/2002#)
|
by: jnikle |
last post by:
I have two completely unrelated tables, one for reviews and another for
pay periods. The reviews table has a review date in it, and the pay
periods table is just a list of the beginnings of pay periods.
What I need to do is take a given review date and find out which date
in my pay periods table it's closest to, above or below.
Any help is greatly appreciated.
-Josh
| |
by: Wes Peters |
last post by:
I have a situation where I want to filter records for a given day. The
field that stores the date/time uses the date() function as a default value,
kind of a date/time stamp for the record.
The problem is when I want to filter records for a given day instead of a
date range. I use the CONVERT function to return just the date part of the
field (101 as a style parameter) and compare that to a start and stop date
(both being the same) and...
|
by: Lysander |
last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the date is more than 10 months out.
The query runs fine, but I when I put the criteria of >10 I get 'Data Type mismatch' error. The code below is the original query. I have since put all the datediff bit in code, with all variables declared as date,...
|
by: Coll |
last post by:
I have a function that calculates a period of time e.g. 2.3 years, .5
years etc. I was using the function in a query, but since I had not
declared a data type for the function, it wasn't sorting numerically
in my query. Can you help me figure out which data type is appropriate
for my function. I tried type Long, but that doesn't seem to include
decimals. I tried Single, but I can't seem to round it to just one
decimal (I tried in the...
|
by: yasirmturk |
last post by:
Standard Date and Time Functions
The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all.
They are simple, easy, and brief and you should use them any time you need to incorporate any date literals or date math in your T-SQL code.
create function DateOnly(@DateTime DateTime)
-- Returns @DateTime...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |