date-format

MySQL Group By Dates Between

不问归期 提交于 2019-11-28 09:04:08
问题 Is there a way to group records that fall between two dates? For example, my table has records that look like this: rid stamp uid 25 2005-07-05 14:10:29 25 1175 2005-08-12 15:47:35 29 290 2005-11-22 16:38:53 42 30 2005-12-01 10:48:12 47 30 2006-01-02 17:34:28 52 30 2006-02-06 22:11:35 57 30 2006-04-17 15:10:19 59 1195 2006-05-08 21:55:56 62 100 2006-06-30 15:51:04 94 45 2006-07-03 21:14:37 24 I'm trying to write a query that will return a count of records between the months of February -

Datetime conversion error for 1 sql server, but not another

让人想犯罪 __ 提交于 2019-11-28 08:55:46
问题 I've got 2 servers running SQL Server 2008, and I have the following query: SELECT cast('13/1/2011' as datetime) If I execute this query on Server A I get the result: 2011-01-13 00:00:00.000 However, if I execute this on Server B I get the result: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. I believe this to be a UK/US date format issue as I don't get an error with 12/1/2011 but it does return 2011-12-01 00:00:00.000 How can I get Server B

Java datetime format convert

╄→尐↘猪︶ㄣ 提交于 2019-11-28 08:54:00
问题 date here my problem: String datetime = "2012-03-24 23:20:51"; I know that that string is in UTC timezone. I need to convert this string to format "yyy-mm-dd'T'HH:mm:ssZ". To do this I'm using following code: SimpleDateFormat inFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); inFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); Date inDate = inFormatter.parse(datetime); SimpleDateFormat outFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); outFormatter.setTimeZone(TimeZone

Formatting a String date into a different format in Java

荒凉一梦 提交于 2019-11-28 06:46:52
问题 I am trying to format a JSON which has a date key in the format: date: "2017-05-23T06:25:50" My current attempt is the following: private String formatDate(String date) { SimpleDateFormat format = new SimpleDateFormat("MM/DD/yyyy"); String formattedDate = ""; try { formattedDate = format.format(format.parse(String.valueOf(date))); } catch (ParseException e) { e.printStackTrace(); } return formattedDate; } But in this occasion, the result isn't shown in my app, the TextView is invisible and I

Format a date from inside a Handlebars Template in Meteor

坚强是说给别人听的谎言 提交于 2019-11-28 03:57:33
I got a ISO formatted Date from my Data and what I actually want to do, is to modify my date format directly from my Templates. like this: {{format my.context.date "myFormat"}} I'm using the moment library, so I could write something like this: {{formatDate my.context.date "DD.MM.YYYY HH:mm"}} // 03.09.2013 18:12 It would be nice, because I think it's the place where I should be able to do this. In my template. Boris Kotov The solution is quite simple, and maybe someone will find it useful. In most projects you have a couple of date formats you want to use. So it's a good approach to define

How to convert the date value “26th May 2017” to “26/05/2017”? [duplicate]

为君一笑 提交于 2019-11-28 02:29:58
This question already has an answer here: Parsing a date’s ordinal indicator ( st, nd, rd, th ) in a date-time string 4 answers Parsing dates of the format “January 10th, 2010” in Java? (with ordinal indicators, st|nd|rd|th) 4 answers Is there any java library available to parse language specific ordinal indicator/suffix? I have a date value like the following: 26th May 2017 . I want to convert this to 26/05/2017 . Could anyone please guide me how to do? You can parse this format directly to a Java 8 LocalDate using a custom date format: static final Map<Long, String> ORDINAL_DAYS = new

How to get Date in the same format as String

家住魔仙堡 提交于 2019-11-28 02:26:27
I want to get the Date object which contains Date in the form yyyy-mm-dd after adding few months to existing Date object. Using DateFormat object I have tried this way but its not giving the output as I want. How can I get this Date format in Java? My code- Calendar c=Calendar.getInstance(); DateFormat sdf=new SimpleDateFormat("yyyy-mm-dd"); Date d=cal.getTime(); c.add(Calendar.MONTH,10); Date newd1=c.getTime(); String news=sdf.format(newd1); Date dnew=(Date)sdf.parse(news); String news has the date of format yyyy-mm-dd but when I use parse on that String it results Date object which is of

Java: Getting time interval

久未见 提交于 2019-11-28 02:14:35
I am on a project to capture the interval time in hh:mm. I have 2 buttons named btnTimeOut & btnTimeIn both capturing the system time when clicked. The requirement is to get the interval between the btnTimeOut & btnTime in hh:mm, etc. 12:30 - 10:00 = 02:30 (hh:mm). Currently I used the following codes for the interval but it returns as minutes, etc. 12:30 - 10:00 = 150 minutes. String timeOut = lblTimeOut.getText(); String timeIn = lblTimeIn2.getText(); SimpleDateFormat format = new SimpleDateFormat("hh:mm"); Date d1 = null; Date d2 = null; try { d1 = format.parse(timeOut); d2 = format.parse

Remove blank-padding from to_char() output

僤鯓⒐⒋嵵緔 提交于 2019-11-28 02:02:22
I generate a view from this: create or replace view datetoday as select to_char(dt, 'yyyy-mm-dd') as date, to_char(dt, 'Day') as weekday from (select ('2013-03-01'::date + i) dt from generate_series(0,'2013-03-03'::date - 2013-03-01'::date) as t(i)) as t; It gives me the weekday info as text type. Then I use: select date::date, weekday::varchar from datetoday; Now the table is like 2013-3-1 Friday 2013-3-2 Saturday If I want to choose the entry: select * from datetoday where weekday='Friday' to change it from text to character varying . It seems that the length is fixed is not according to

Convert Date from one format to another format in JavaScript

孤人 提交于 2019-11-28 01:12:37
I have a string of a date in javascript in format #1. I need to convert it to format #2. The problem starts when one format is "dd/mm/yy" and the other is "mm/dd/yy". The formats change dynamically and I have the formats as strings, but I need a function like Date newDate = convert(currentDate, currentFormatString, newFormatString). How can I do it? You should look into momentjs , which is a javascript date/time library. With that, you can easily convert between dates of different format. In your case, it would be: string newDate = moment(currentDate, currentFormatString).format