SQL queries valid data within three days

Source: Internet
Author: User
Tags stringbuffer

The launch dots occurred.

StringBuffer SB =NewStringBuffer (); Sb.append ("Select dmp.* from Drug_presc_master where 1=1"); SimpleDateFormat format=NewSimpleDateFormat ("Yyyymmddhhmmss"); Calendar Now=calendar.getinstance (); Now.settime (NewDate ()); Now.add (Calendar.date,1); Now.set (Calendar.hour_of_day,0); Now.set (Calendar.minute,0); Now.set (Calendar.second,0); Calendar begindate=calendar.getinstance (); Begindate.settime (NewDate ()); Begindate.add (Calendar.date,-displaytime + 1); Begindate.set (Calendar.hour_of_day,0); Begindate.set (Calendar.minute,0); Begindate.set (Calendar.second,0); Sb.append ("and DPM. Presc_date >= to_date (' "). Append (Format.format (Begindate.gettime ())). Append (" ', ' Yyyymmddhh24miss ') "); Sb.append ("and DPM. Presc_date < To_date (' "). Append (Format.format (Now.gettime ())). Append (" ', ' Yyyymmddhh24miss ') ");

Following date execution results

SimpleDateFormat format =NewSimpleDateFormat ("Yyyymmddhhmmss"); Calendar Now=calendar.getinstance (); Now.settime (NewDate ()); Now.add (Calendar.date,1); Now.set (Calendar.hour_of_day,0); Now.set (Calendar.minute,0); Now.set (Calendar.second,0); Calendar begindate=calendar.getinstance (); Begindate.settime (NewDate ()); Begindate.add (Calendar.date,-displaytime + 1); Begindate.set (Calendar.hour_of_day,0); Begindate.set (Calendar.minute,0); Begindate.set (Calendar.second,0); System.outp.println (Now.gettime ()); System.outp.println (Begindate.gettime ()); System.outp.println (Format.format (Now.gettime ())); System.outp.println (Format.format (Begindate.gettime ()));------------------------------------------Execution Result now.gettime (): Sun Oct 00:00:00 CST 2017begindate.gettime (): Thu Oct 00:00:00 CST 2017format.format (Format.format (Now.gettime ())) : 20171012000000format.format (Begindate.gettime ()): 20171015000000

Sb.append ("and DPM. Presc_date >= to_date (' "). Append (Format.format (Begindate.gettime ())). Append (" ', ' Yyyymmddhh24miss ') ")

Dpm. Presc_date: stored in the database in the form of 2017/8/7 19:11:27

SQL queries valid data within three days

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.