Showing posts with label date. Show all posts
Showing posts with label date. Show all posts

How to change string to DATETIME in SQL?


SET `time_str` = STR_TO_DATE(`time_str`,'%d/%m/%Y %H:%i')

Java Date to SQL DateTime with timestamp

Date class is java.util.Date and while it is formatted as String (currentTime below), it can be inserted into DB field set as DATETIME.

                     // Change to string store in MySQL (DATETIME)  
                     Date dt = ugc.getCreate_time();  
                     java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
                     String currentTime = sdf.format(dt);  

Inserted record format: 2013-11-04 14:09:59

Example - Date


  • Use funtion

 > d1 <- date()  
 > class(d1)  
 [1] "character"  
 > d1  
 [1] "Tue Dec 23 17:46:34 2014"  
 > d2 <- Sys.Date()  
 > class(d2)  
 [1] "Date"  
 > d2  
 [1] "2014-12-23"  
 > format(d2,"%a %b %d")  
 [1] "Tue Dec 23"  
 > d3 <- "1jan2014"  
 > d4 <- as.Date(d3,"%d%b%Y")  
 > d4  
 [1] "2014-01-01"  
 > d2 - d4  
 Time difference of 356 days  
 > as.numeric(d2-d4)  
 [1] 356  
 > weekdays(d2)  
 [1] "Tuesday"  
 > months(d2)  
 [1] "December"  
 > julian(d2)  # days from origin date (1970-01-01)
 [1] 16427  
 attr(,"origin")  
 [1] "1970-01-01"  

  • Use library

 > library(lubridate)  
 > ymd("20140108")  
 [1] "2014-01-08 UTC"  
 > ymd_hms("2014-01-01 10:10:10")  
 [1] "2014-01-01 10:10:10 UTC"  
 > ymd_hms("2014-01-01 10:10:10", tz = "Pacific/Auckland")  
 [1] "2014-01-01 10:10:10 NZDT"  
 > wday( ymd("20140108"))  
 [1] 4  
 > wday( ymd("20140108"), label = TRUE)  
 [1] Wed  
 Levels: Sun < Mon < Tues < Wed < Thurs < Fri < Sat  

TOEFL paper report receive date

Due to the Visa application, I called the ETS office to inquiry about when I could get the TOEFL paper report for the test at 18th Jan.

As the administrator told to me, it will send from ETS three days later after the score is available online, and will take 4-6 weeks after that to be sent to the place you live.

In general, the date will be organized as below to receive the paper report.

  • Test Date : 18th Jan.

  • Score available online : 29th Jan.

  • Sent from ETS : 1st Feb.

  • Receive 4-6 weeks later