CSV date Format issue - c#-3.0

When I am using date in a .csv file it creats a problem as like I have used 01/01/2011 it takes 1st jan 2011,that's right but when I use 01/10/2011 it takes it as 10th jan 2011. I mean to say it always takes in mm-dd-yyyy format. I have some gb of files are there to be converted into csv. When I am converting these files dates in the files are in dd-mm-yyyy format. And after conversion the value changes completely.Hence How to resolve this issue? Hope I made my requirement clear.

Try the following:
DateTime.ParseExact("01/10/2011","dd/mm/yyyy",CultureInfo.CurrentCulture);
This specifies the format of the date in the string and should convert your dates correctly.

Related

Google sheets won't format time date correctly

My Google Sheets is currently set to UK London GMT
I have some data that is needed in UK format and other data that is needed in US format within the same sheet.
I'm using date time as dd-mm-yyyy hh:mm:ss and have been trying to convert this to US yyyy-mm-dd hh:mm:ss
When formatting the UK date time to as text and using this formula
=ARRAYFORMULA(REGEXREPLACE(A2:A, "(\d{4})-(\d+)-(\d+)", "$3/$2/$1"))
It should be converting for me however is stays the same.
I have also tried simply copying and pasting in a new column with the intention of changing format from within formatting settings but when pasting it seems to randomly select different formats in some rows using / instead of - and in other rows returning a number instead of date time.
How can I get this to work correctly?
try:
=TEXT(A2, "e-m-d h:mm:ss")

I am using OpenXML in C# for creating xlsx file but date comes as Jan 1900

In C# I am using OpenXML document format spreadsheet to create xlsx file. but excel gets created with date 'Jan 1900'. I am applying stylesheet document to spreadsheet document. Please help to get exact date.
I expects date should be 01/01/2019 which comes from datatable but actual output is Jan 1900
I think one of the solutions is to use the TEXT function.
Let's say you have a variable contains the date named dDate.
Then, put this in the cell where you want the value to be displayed:
=text(dDate,"mm/dd/yyyy")
Maybe you need to use C# grammar to do the concatenation of the string and the variable.

Date format issue while uploading and saving the excel sheet into db using coldfusion cfspreadsheet

I uploaded and parsed through an excel sheet using cfspreadsheet and inserted all the values into database and the problem is that [my excel sheet has a date range from 1/2/2016 to 29/02/2016,from 1/2/16 to 12/2/2016 it is right aligned in excelsheet and remaining is left aligned...]. The value is being inserted into the db but I cannot able to fetch the values from 1-12 using where condition in db. I tried manually changing the date format in my excel sheet..what happened is
..02 January 2016
02 February 2016
.
.
02 December 2016
13/02/2016
14/02/2016
.
.
up to 02/12/2016[mm/dd/yy] it is displaying dd as month notation and from 13/02/2016[dd/mm/yyy] it is displaying properly, I tried with all formatting options, and I need to implement it in code. I think while downloading the data itself the date is not getting formatted properly, I tried with different excel sheet but of no use...and I tried converting these dates into specific format using coldfusion code and but it doesn't works for me..
<cfset sheet = spreadSheetRead("D:\file123\final1231.xls")>
<cfset SpreadSheetFormatColumn(sheet,{dataFormat="yyyy-mm-dd"},3)>
<cfset SpreadSheetWrite(sheet,"D:\file123\final1232",true)>
can any one help me in this?
What looks to me is that locale is set to 'English (United States)' in your excel and that is why for first 12 rows your excel is treating values as valid date but starting 13th row the data is invalid and hence excel is treating it as string (hence left aligned). Try manually changing excel locale to 'English (India)' or similar and you will see data aligned properly.
Also Cold Fusion internal date-time format is American (mm/dd/yyyy) and by default will interpret date and time into American format. I think while inserting data you can create date with something like below to make sure what data gets inserted:
#createDate(listLast(dt,"/"),listFirst(listRest(dt,"/"),"/"),listFirst(dt,"/"))#
Here dt is the data column that you want to insert. You may need to put some checks, based on the data, to avoid any run time errors.

Invalid date value in csv file

I export data in csv format from sql server database. It contain 5 column. one column have date and time value. When i checked the date -time value i found date time value is in wrong format. I add the filter but filter not applied on some data. I try to format the data in same format but formatting did not applied on the data. I tried everything to fix the issue but it is not getting fix.
I have attached the sample data please check it from your end.
7/12/2013 14:50
8/12/2013 20:14
9/12/2013 11:38
10/12/2013 15:31
13/12/2013 12:45:50
13/12/2013 14:35:42
13/12/2013 14:37:40
14/12/2013 17:00:10
18/12/2013 14:57:35
Data started from 13/12/2013 12:45:50 are not getting change in date time format.
The trouble is that your dates are in french format dd/mm/yyyy you can force them to datetime with the following line :
[datetime]::ParseExact("7/12/2013 14:50", "d/MM/yyyy HH:mm", $null)
[datetime]::ParseExact("13/12/2013 12:45:50", "d/MM/yyyy HH:mm:ss", $null)
Be carefull in you case sometime you've got seconds and a double space between day and time.

Btrieve Date Integer

this is my question:
I'm migrating data from a Btrieve file (.dat) through Pervasive Control Center and there is field type which is defined as integer but is a date and for example the date '31/12/2009' (seen in the legacy system) is view it as the number 733772 when I export it.
The legacy system shows the date correctly but I can't export it in the same format or at least I can't convert it. Does anybody know how to convert this number through Excel or something?
When I divided 733772 by 365.2425 (Number of days in year considering Leap year and 29 days of Feb - http://www.timeanddate.com/date/leapyear.html), it gave back 2009.
Go to format cells and changing category to date.