Solved

load based upon date

Posted on 2011-09-19
6
256 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 500 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Application Local DB Connection String 23 113
Write Caching in the Cloud for VFP9 16 89
dbcc checkdb datawarehouse 2 41
Unrecognized Database Format 8 93
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now