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

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.

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")

Google Sheets - Date Format Display Issues

I'm currently building dashboards in Google Sheets and have run into a consistent issue with dates being displayed as a number opposed to a date format. EX: 43626 opposed to 6/11/19.
This data is being pulled from form sheet into a database, then queried into the dashboard spreadsheet where it is coming through as a number sequence opposed to readable date format. Currently have tried to use the DATEVALUE to reformat, as well as attempted to reformat the cell into a date format in both dashboard and database locations, with no luck.
//What I've tried
=TargetCell
43626
=DATEVALUE(TargetCell)
43626
=TargetCell //Reformatted as any Date format
43626
I was expecting the following
=DATEVALUE(TargetCell)
6/11/19
OR:
=TargetCell //Reformatted as any Date format
6/11/19
you got it wrong... function DATEVALUE creates 43626 from 6/11/2019
if you want to reverse it you need to use either:
internal custom date formatting (does not work all the times)
TEXT formula like: =TEXT(43626, "m/d/yy")
QUERY parameter format like: =QUERY(A:B, "format A 'm/d/yy'", 0)
or QUERY parameter toDate like: =QUERY(A:B, "toDate(A)", 0)
https://developers.google.com/chart/interactive/docs/querylanguage#top_of_page

Having an issue with ascertaining the format of a date

I've been tasked with getting data from an existing database table and transferring it into another. Everything is fine except the date in the original table is in a format that I don't recognise. It looks suspiciously like a unix timestamp but when converting it it seems to be coming out as the year 2727 or something.
Here is an example of what's in the existing table: 1424786878240
The matching date for this on the front end of the site is 24th February 2015. I cannot seem to find any correlation between this and the number in the database - and since I have no access to the original site code I am unable to determine how it's being converted.
If anyone recognises this date format / structure I would appreciate some help.

Convert Date Value When Using Google Form Date Picker from 5 Digit Format to MM/dd/yyyy format

I selected tomorrow's date (8/21/2014) from the data picker field of a Google Form submission, and the value "41872" is returned in the spreadsheet.
What format is this date format?
I need to convert this date format to the MM/dd/yyyy format using script, as formatting the Date column using the Format menu only updates the rows that are currently available...not the new rows that will be there when new form submissions come in.
How do I make this conversion?
I am not sure, but your issue seems to be very basic. Its about the cell formatting as like we do in Ms Excel.
For Google spreadsheet inorder to format a cell or a range,
1. Select the Range
2. On menu, Go To Format->Number->Date (and then select the required format)
Does this works?
I had the same confusion. All you need to do is just change the format from the menu Format->Number->Date & Time

Dates in Table are submitted in incorrect regional format

Background Info
I currently have a VBA user form, which submits daily KPIs to an Excel Table in Excel 2010. The Form is setup to put today's date into a text box in the format DD/MM/YYYY (I'm in Australia), then transfer that information to the Excel worksheet when I hit submit. Previously, this process has worked without a hitch, as it is just transferring pure text. But now, the date is being submitted in US format (MM/DD/YYYY). I'm pretty sure the problem is somewhere in Excel, but here is my VBA code anyway:
'First it populates the text box
Private Sub UserForm_Activate()
TextBox1.Text = Format(Now(), "DD/MM/YYYY")
End Sub
'Then it transfers to the spreadsheet
With nwb.Sheets("daily_tracking_dataset_master")
.Cells(emptyRow, 1).Value = TextBox1.Value
Main Problem
Somewhere on the Excel side, the data is now being submitted incorrectly in the US date format, so a submission on the fourth of June, becomes the sixth of April, see image: http://tinypic.com/r/2vslyd5/8/.
When i change the number format to General, it shows that the pure text date from the VBA form has been converted to the April date. I.e. it's not a simple matter of changing the formatting, the date has actually been completely changed:
41789 (30/05/2014)
41789 (30/05/2014)
41789 (30/05/2014)
41735 (06/04/2014)
41735 (06/04/2014)
41735 (06/04/2014)
I have tried several workarounds for this, including:
Highlighting column A and changing the format to Date in the format DD/MM/YY
Selecting Date format under the Home tab -> Number group -> Date drop down box
Checking regional settings in Windows and Excel
I have also tried going into Data -> Data Tools -> Text to columns. Then on step 3 selecting DMY under Date - this seems to be one of the main fixes for the issue I'm having in other forums.
By the nature of the Excel Table, each time my submission form adds a record, the table is extended by one row - I'm not sure whether this would have any influence and the incorrect date settings are generated from the Table somehow?
Any ideas for troubleshooting this would be fantastic.
You need to use CDate when writing back to the cell to convert the text to a real date value so that VBA can't misinterpret it:
.Cells(emptyRow, 1).Value = cdate(TextBox1.Value)