Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-06-2023, 09:09 AM
ArviLaanemets ArviLaanemets is offline Converting a date to sring using FORMAT() gives wrong format Windows 8 Converting a date to sring using FORMAT() gives wrong format Office 2016
Expert
Converting a date to sring using FORMAT() gives wrong format
 
Join Date: May 2017
Posts: 873
ArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud of
Default Converting a date to sring using FORMAT() gives wrong format

Hi



I'm creating an Excel converter app, which reads data from client's forecast file, and writes a text file used to import those data to ERP program.

I tried in VBA procedure to convert date to string, using code like:
Code:
...
strDateString = Format(datDate, strDateFormat)
...
where strDateformat is "dd/mm/yyyy" (it is read from Setup sheet of converter, i.e. user can determine, what the format must be). The local date format for my computer is "dd.mm.yyyy", and this is the format the VBA returns. (And this is really what the Format() function returns - I checked it in Immediate window!). So what about Format function converting the date to string in given format?
Reply With Quote
  #2  
Old 09-13-2023, 11:24 AM
BobBridges's Avatar
BobBridges BobBridges is offline Converting a date to sring using FORMAT() gives wrong format Windows 7 64bit Converting a date to sring using FORMAT() gives wrong format Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Just a notion, but you say you're writing out the results in a text file. Any chance you mean it's CSV? A CSV doesn't know anything about formatting. If not, we might need more detail about how you know what format is being returned. I know, it sounds silly, but silly mistakes do exist out there.
Reply With Quote
  #3  
Old 09-14-2023, 10:23 PM
ArviLaanemets ArviLaanemets is offline Converting a date to sring using FORMAT() gives wrong format Windows 8 Converting a date to sring using FORMAT() gives wrong format Office 2016
Expert
Converting a date to sring using FORMAT() gives wrong format
 
Join Date: May 2017
Posts: 873
ArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud of
Default

The target file for this particular SetUp is a text file, which is used to import some info (sent by client) into ERP application. The converter may be used in one country, or by person having any local settings in his/her computer, and ERP application may be work in entirely another country. And the client my reside in third country. The format the imported dates must have, is determined on converter's SetUp sheet.

In converter's SetUp, the user determines settings for source and target file (file types of source file can be like text file, or Excel workbook, or CSV file, or HTML-file, and are in SetUp determined for client).

Then user clicks a button to read in the source file, and app checks the source file structure and the presence of data in it, after that reads the source file data in (source file type is determined in and makes all nesseccary calculations - like source table can have data table like list, or may have the table where data is stored columnwise, or there are weekly, or monthly rows and those must be consolidated or distributed according the SetUp, etc.). And finally read in and converted data are writen into converter's target table, having one column there for dates in datestring format usable for ERP application, the forecast is meant to.

Clicking the another button, the app reads the data of certain forecast from converter's table, and writes those data into text file in format readable by ERP application (all this based on Setup settings again).

I mark the case closed, as I simply got the datestring composed from year, month and day strings, using some amount of script to analyze the date format string determined in app's SetUp to do this properly.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail merge field mistakenly interpret text format as date format alan6690 Mail Merge 0 09-02-2020 01:54 AM
Date is displayed in the wrong format shawn.low@cox.net Mail Merge 1 12-28-2019 02:17 AM
Converting a date to sring using FORMAT() gives wrong format Converting letter format documents to A4 format TJB Word 1 06-01-2016 06:35 AM
Converting a date to sring using FORMAT() gives wrong format converting mm.s format to mm:ss derohanes Excel 12 10-30-2012 08:34 AM
Converting a date to sring using FORMAT() gives wrong format Converting from DOC files to PDF format obenix Word 2 04-29-2005 04:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft