473,786 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Urgent : Help to convert string to date

1 New Member
Hi
My requirement is to compare a date in string format with the Sysdate. The problem is the date string does not contain a zero before the single digit date and month.

Here is my query

select * from table_name where to_date(%date%, 'MM/DD/YYYY) > (SYSDATE - 7);

this gives an error saying the month is not valid when the month in %date% is single digit.
Please help

Thanks
Oct 17 '07 #1
3 2788
amitpatel66
2,367 Recognized Expert Top Contributor
Hi
My requirement is to compare a date in string format with the Sysdate. The problem is the date string does not contain a zero before the single digit date and month.

Here is my query

select * from table_name where to_date(%date%, 'MM/DD/YYYY) > (SYSDATE - 7);

this gives an error saying the month is not valid when the month in %date% is single digit.
Please help

Thanks
This error is because the NLS_DATE_FORMAT is something different for your session from the format that you are using.

Run the below query in your session before running the above select statement:

Expand|Select|Wrap|Line Numbers
  1. ALTER SESSION SET NLS_DATE_FORMAT = 'MM/DD/RRRR';
  2.  
Oct 18 '07 #2
cheguvera
7 New Member
Hi,

This may not look pretty but, if you run a query,

select ltrim(to_char(s ysdate - 195,'DD'),'0') || '/' || ltrim(to_char(s ysdate - 195,'MM'),'0') || '/' || to_char(sysdate - 195,'YYYY') from dual

you will see the system date in dd/mm/yyyy format without zeros.
All I have done is put a ltrim on to_char and trimmed the day and month saperately and then appended them.

You can use such string and directly equate with your date.

Regards
Oct 19 '07 #3
susarlasireesha
5 New Member
select * from emp
where to_date(to_char (sysdate,'mm/dd/yyyy'),'mm/dd/yyyy') > to_date(to_char (SYSDATE-7,'mm/dd/yyyy'),'mm/dd/yyyy');
Try this........... .......
Oct 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
1433
by: Dinçer | last post by:
I need to compare dates. But this way: I get a date from database. I need to understand if this date is newer then "6 months" or not. What I need is get the current date, calculate the date 6 months ago, compare "the date from DB" & "the date 6 months ago from now" show the result.
0
1899
by: john | last post by:
Hi,All MS Tech Gurus: I need your help!!! It is the second time I post this message, I need get some feedback ASAP, Please Help!! Thanks a lot in advance. John I have a csharp method, using emit to dynamically generate classes & method depends on the meta table in the database,here is my situation 1) In One method I generated the code Dynamic IL Code (Depends on the data pass to it), The generated code works for one dataset but does...
12
3862
by: DC Gringo | last post by:
How can I convert this pubLatest to a date with format "m/d/yyyy"? Dim pubLatest As New Date pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Value -- _____ DC G
5
3505
by: Vishal | last post by:
Hey, I have differnt kind of dates. They can be in this format: Thur, 23 Sept 2004 14:24:15 GMT Thur, 23 Sept 2004 14:24:15 PST Thur, 23 Sept 2004 14:24:15 CST and so on....
16
2968
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In: http://www.mywebsite.org/WebResource.axd?d=5WvLfhnJp5Lc8WhQSD4gdA2&t=632614619884218750 -------------------------------------------------------------------------------- System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed. at...
7
4072
by: meenasamy | last post by:
Hi all, i need to create a function that takes three parameters( Original currency, needed currency, amount) i need to convert from the original currency to the needed currency the amount and return the new amount in the needed currency, I need this function to work real time (obtaining real time currency exchange rates), any ideas???
3
2092
by: ricolee99 | last post by:
Hi everyone, I have a problem that i have been trying to solve for awhile. I'm given a code where the purpose is to create a general dataset mapper. Given any dataset, i have a class, "Mapper.cs" that's supposed to map objects from any type of dataset to any type of object. Inside Mapper.cs, there's a method, object Map(Type typeOfObjectToMap, DataSet theDataSet)
32
7204
by: jamieexley | last post by:
what are the parameters needed in the constructor call below to create a Date variable whose intitial value is the 15th of March 2004????
2
8565
by: santoshpayal | last post by:
Hi, I have a text file that contains a date column. The text file will be imported to database in SQL 2000 server. After to be importing, I want to convert the date column to date type. For ex. the text file look like Name date Smith 06092006 023718
0
9496
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
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...
0
9961
tracyyun
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...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
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...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.