Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

load based upon date

Posted on 2011-09-19
6
Medium Priority
?
301 Views
Last Modified: 2013-11-16
I have two columns createdt and changedt both character 14 looks like (20101108140439) I want to do daily load based upon these two dates with date() function

So sumthing like this if createdt or changedt changed in last 2 days capture those last 2 days and insert data

Select * from aa
Where createdt or changedt <= date() -2 days

Other thing is we have global macro &loaddt if I want to use that
Instead of date() how can I do tht.
0
Comment
Question by:sam2929
  • 3
  • 3
6 Comments
 
LVL 14

Expert Comment

by:Aloysius Low
ID: 36565013
what you could do is to compare date() - 2 against substring of createdt and changedt in your where condition:
where input(substr(createdt, 1, 8), yymmdd8.) <= date() - 2 or input(substr(changedt, 1, 8), yymmdd8.) <= date() - 2

if you have a macro loaddt and that variable already stores a numeric date value, then you could simply replace date() with &loaddt, otherwise, you'll need to convert the value stored in &loaddt into numeric first, so it all depends on how the value in &loaddt is stored
0
 

Author Comment

by:sam2929
ID: 36566542
i am running the below query which should pick last 2 days but its just picking all the days

select createddt,input(substr(createddt, 1, 8), yymmdd8.),date() from aa
where input(substr(createddt, 1, 8), yymmdd8.) <= date() - 2
0
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 2000 total points
ID: 36566837
my mistake, it should be >= instead

otherwise, it might be safer to use in (date() - 1, date() - 2) to explicitly state the 2 dates that you are interested in...
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:sam2929
ID: 36566875
what if the date format is date9. what format should where caluse be then
0
 

Author Comment

by:sam2929
ID: 36566882
what if the createddt format is date9. what format should where caluse be then
0
 
LVL 14

Expert Comment

by:Aloysius Low
ID: 36566889
anydtdte should work
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Jet database engine errors can crop up out of nowhere to disrupt the working of the Exchange server. Decoding why a particular error occurs goes a long way in determining the right solution for it.
Exchange database can often fail to mount thereby halting the work of all users connected to it. Finding out why database isn’t mounting is crucial and getting the server back online. Stellar Phoenix Mailbox Exchange Recovery is a champion product t…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question