Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


load based upon date

Posted on 2011-09-19
Medium Priority
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.
Question by:sam2929
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
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

Author Comment

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
LVL 14

Accepted Solution

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...
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf


Author Comment

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

Author Comment

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

Expert Comment

by:Aloysius Low
ID: 36566889
anydtdte should work

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

715 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