getdate

How to get a Date from a JSON object

时光总嘲笑我的痴心妄想 提交于 2019-11-30 08:09:44
I have a JSON object, which have one field that is a birthdate: JSONObject obj = new JSONObject(response); User user = new User(); user.setuserID(obj.getString("userID")); user.setisMale(obj.getBoolean("isMale")); user.setEmail(obj.getString("email")); // user.setBirthdate(obj.getDate("birthdate")); user.setLastName(obj.getString("lastName")); user.setFirstName(obj.getString("firstName")); But the method getDate() does not exist in JSONObject. How can I set the Birthdate in my User object? You may do like below, String dateStr = obj.getString("birthdate"); SimpleDateFormat sdf = new

Selecting GETDATE() function twice in a select list— same value for both?

浪子不回头ぞ 提交于 2019-11-29 13:29:31
I have a SELECT statement that uses GETDATE() for two different column values. I'm wondering if by the nature of things those two separate function calls in the same SELECT will return identical values every time? No they aren't guaranteed to return identical values every time. Each individual reference to GetDate() is a runtime constant and will keep its value throughout the query... SELECT GETDATE() FROM large_table will return the same value in all rows regardless of how long the query takes to run. But there is no guarantee that different references will have the same value. You can see

Get date using javascript in this format [MM/DD/YY]

爷,独闯天下 提交于 2019-11-29 04:28:49
how can I get the date in this format [mm/dd/yy] using javascript. I am struggling to get the 'year' to a 2 digit figure as opposed to the full 4 digits. Thanks! Try this: HTML <div id="output"></div> JS (function () { // Get current date var date = new Date(); // Format day/month/year to two digits var formattedDate = ('0' + date.getDate()).slice(-2); var formattedMonth = ('0' + (date.getMonth() + 1)).slice(-2); var formattedYear = date.getFullYear().toString().substr(2,2); // Combine and format date string var dateString = formattedMonth + '/' + formattedDate + '/' + formattedYear; //

SSIS expression: convert date to string

扶醉桌前 提交于 2019-11-28 23:11:45
I'm new to SSIS and I'm trying to convert a GetDate() to string "DD-MM-YYYY". This is the expression I've built so far: (DT_WSTR, 8) DAY( GETDATE()) + "-" + (DT_WSTR, 8) (MONTH(GETDATE()) - 1) + "-" + (DT_WSTR, 8) YEAR(GETDATE()) The problem I've got is Month() converts the Month "23-4-2013" to a single character when I want it in Double character, same as day. How do i make it into a double character no matter what month it is? For SSIS you could go with: RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd" , GETDATE()), 2) + "-" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm" , GETDATE()), 2) + "-" +

Changing the output of Getdate

北城余情 提交于 2019-11-28 13:24:32
Is it possible to deceive SQL Server to return a different date on GetDate() without actually changing the machine date? This would be great, since we have a database with old data and I'm trying to test some queries that use getdate(). I can change my machine date but that brings some other problems with other applications... Any tips? Thanks! According to the documentation for getdate() : This value is derived from the operating system of the computer on which the instance of SQL Server is running. Since it's derived from the OS, I don't think you can change it separately. You can always

Ordering WP Posts by Custom Meta Key

末鹿安然 提交于 2019-11-28 07:52:26
问题 I created a WordPress custom post type to be able to create events, select the event's date, and display the date on the frontend. I added a new meta_key in the postmeta of WP's database to store the event's date in a UNIX timestamp. I've had no trouble creating a new WP query to output my events on my site but I am trying to figure out how to organize the events by their UNIX timestamp in the database, not by the date that WordPress created the events. I can't seem to wrap my head around the

Getting the date from a ResultSet for use with java.time classes

折月煮酒 提交于 2019-11-27 20:38:23
Is there anyway to get a java.time (new in Java 8) compatible time class out of a ResultSet ? I am aware you can use ResultSet 's getDate or getTimestamp but these method return java.sql.Date / java.sql.Timestamp objects which are now deprecated so it seems like bad practice to use them in order to create a ZonedDateTime or similar. Meno Hochschild Most database vendors don't support JDBC 4.2 yet. This specification says that the new java.time -types like LocalDate will/should be supported using the existing methods setObject(...) and getObject() . No explicit conversion is required and

JDBC ResultSet: I need a getDateTime, but there is only getDate and getTimeStamp

旧街凉风 提交于 2019-11-27 19:15:50
I would like to get the DATETIME column from an Oracle DB Table with JDBC. Here is my code: int columnType = rsmd.getColumnType(i); if(columnType == Types.DATE) { Date aDate = rs.getDate(i); valueToInsert = aDate.toString(); } else if(columnType == Types.TIMESTAMP) { Timestamp aTimeStamp = rs.getTimestamp(i); valueToInsert = aTimeStamp.toString(); } else { valueToInsert = rs.getString(i); } I have to identify the column type first. The field I am interested in is recognized as a Types.DATE, but it is really a DATETIME in the DB since it has this format: "07.05.2009 13:49:32" getDate truncates

Get date using javascript in this format [MM/DD/YY]

余生长醉 提交于 2019-11-27 18:27:15
问题 how can I get the date in this format [mm/dd/yy] using javascript. I am struggling to get the 'year' to a 2 digit figure as opposed to the full 4 digits. Thanks! 回答1: Try this: HTML <div id="output"></div> JS (function () { // Get current date var date = new Date(); // Format day/month/year to two digits var formattedDate = ('0' + date.getDate()).slice(-2); var formattedMonth = ('0' + (date.getMonth() + 1)).slice(-2); var formattedYear = date.getFullYear().toString().substr(2,2); // Combine

SSIS expression: convert date to string

独自空忆成欢 提交于 2019-11-27 14:46:17
问题 I'm new to SSIS and I'm trying to convert a GetDate() to string "DD-MM-YYYY". This is the expression I've built so far: (DT_WSTR, 8) DAY( GETDATE()) + "-" + (DT_WSTR, 8) (MONTH(GETDATE()) - 1) + "-" + (DT_WSTR, 8) YEAR(GETDATE()) The problem I've got is Month() converts the Month "23-4-2013" to a single character when I want it in Double character, same as day. How do i make it into a double character no matter what month it is? 回答1: For SSIS you could go with: RIGHT("0" + (DT_STR, 2, 1252)