date-conversion

What does bb or bbbb represent in an EN-US TEXT function or Custom Number format mask?

末鹿安然 提交于 2019-11-29 16:52:14
On a EN-US regional system, what does B or b represent in a format mask? While it does nothing in VBA's Format function , both the TEXT function and Custom Number Formatting recognize b as a legal Number Format Code and return a number that I cannot determine the origin of. To further confuse matters, larger numbers return different values when formatted with bbbb and while blocks of sequential numbers return the same value, there are transitions when they jump ahead a digit. I do know that Excel expects the format mask to be either bb or bbbb because if B or b is supplied as a custom number

Datetime conversion error for 1 sql server, but not another

北城余情 提交于 2019-11-29 15:20:44
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 to get the same result as Server A ? What setting needs to be changed and where? It is the language

javascript - regular expression to validate date in mm/dd/yyyy format [duplicate]

萝らか妹 提交于 2019-11-29 11:56:09
This question already has an answer here: Regular Expression to match valid dates 15 answers date formatting with/without Moment.js 4 answers I'm not good at regular expression. I got code to validate dd/mm/yyyy format which also validates leap year, I tried to modify to get it work for mm/dd/yyyy, but they all failed. Can some one change it to validate mm/dd/yyyy format? Regular Expression: ^(((0[1-9]|[12]\d|3[01])/(0[13578]|1[02])/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)/(0[13456789]|1[012])/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])/02/((19|[2-9]\d)\d{2}))|(29/02/((1[6-9]|[2-9]\d)(0[48]|

How convert Gregorian date to Persian date?

安稳与你 提交于 2019-11-29 04:35:49
问题 I want to convert a custom Gregorian date to Persian date in C#. For example, i have a string with this contents: string GregorianDate = "Thursday, October 24, 2013"; Now i want to have: string PersianDate = پنج‌شنبه 2 آبان 1392 ; or string PersianDate = 1392/08/02 Thanks 回答1: Use the PersianCalendar: string GregorianDate = "Thursday, October 24, 2013"; DateTime d = DateTime.Parse(GregorianDate); PersianCalendar pc = new PersianCalendar(); Console.WriteLine(string.Format("{0}/{1}/{2}", pc

Convert “unknown format” strings to datetime objects?

这一生的挚爱 提交于 2019-11-29 03:23:29
This is probably a very basic question but after reading documentation I still can't figure out how to do it... I have two strings in Python that contain dates of unknown format . I don't know what formats they are in, except I know that both are valid date-time expressions. For example, one of them might be in the ISO format and the other in some other format. All I need is to be able to compare the dates. What's the correct way to turn strings into appropriate date-time objects so that they can be compared? thanks! The dateutil module has a date parser which can parse date strings in many

Converting unix time into date-time via excel

谁说我不能喝 提交于 2019-11-28 20:20:07
Trying to convert 1504865618099.00 Unix time into a readable date time. I tried this: =(UNIX + ("1/1/1970"-"1/1/1900"+1)*86400) / 86400 But it's not working. To convert the epoch(Unix-Time) to regular time like for the below timestamp Ex: 1517577336206 First convert the value with the following function like below =LEFT(A1,10) & "." & RIGHT(A1,3) The output will be like below Ex: 1517577336.206 Now Add the formula like below =(((B1/60)/60)/24)+DATE(1970,1,1) Now format the cell like below or required format(Custom format) m/d/yyyy h:mm:ss.000 Now example time comes like 2/2/2018 13:15:36.206

Go / golang time.Now().UnixNano() convert to milliseconds?

邮差的信 提交于 2019-11-28 16:57:16
How can I get Unix time in Go in milliseconds? I have the following function: func makeTimestamp() int64 { return time.Now().UnixNano() % 1e6 / 1e3 } I need less precision and only want milliseconds. OneOfOne Just divide it: func makeTimestamp() int64 { return time.Now().UnixNano() / int64(time.Millisecond) } Here is an example that you can compile and run to see the output package main import ( "time" "fmt" ) func main() { a := makeTimestamp() fmt.Printf("%d \n", a) } func makeTimestamp() int64 { return time.Now().UnixNano() / int64(time.Millisecond) } As @Jono points out in @OneOfOne's

How to convert date format in golang?

别来无恙 提交于 2019-11-28 14:17:12
I would like to convert date format from 2010-01-23 11:44:20 to Jan 23 '10 at 11:44 in golang. I tried few functions from time package but couldn't make it. Could someone help me with this? You could use the time package's Parse and Format to convert it to the desired text format. Both take a reference time (2006-01-02 15:04:05) in the format you require as a parameter which makes the format fairly easy to understand. dtstr1 := "2010-01-23 11:44:20" dt,_ := time.Parse("2006-01-02 15:04:05", dtstr1) dtstr2 := dt.Format("Jan 2 '06 at 15:04") A playground to test with . One way is to use the time

Why does strtotime give different result in different timezone?

被刻印的时光 ゝ 提交于 2019-11-28 13:52:14
I am not sure why strtotime() in PHP returns different result in different timezone even though same date is given as parameter, does anyone know the answer? I also want to know, can I do similar task (converting a datetime to an int to do calculations easily) with another function which gives same result across different timezone? EDIT: An example: If I use strtotime('2011-09-19 00:00:00') shouldn't it just return the difference between 'January 1 1970 00:00:00' and '2011-09-19 00:00:00' in seconds ? Why timezone is an issue here? And can I get something which gives just difference without

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