Solved

Formatting date and time in query

Posted on 2013-05-12
9
529 Views
Last Modified: 2013-05-13
Dear Experts,

I am trying to export a table into a .cvs file, with date and time formatted as:
5/13/2013
16:00

And what I am doing is not working.  I have tried using DateVal(date) and TimeVal(time), tried to format the field as short date and short time, but whatever I have done so far results in:
5/13/2013 0:00
12/30/1899 16:00:00

Please advise.
0
Comment
Question by:yballan
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 33

Expert Comment

by:Norie
ID: 39160034
Instead of exporting the table expost a query based on the table.

It would have all the fields from the table and you can use the Format function with your date/time field(s).

FormattedDateTime:Format([DateTimeField], "mm/dd/yyyy hh:mm")
0
 

Author Comment

by:yballan
ID: 39160072
Dear imnorie,

Thank you for your prompt response, I don't think I know how to export a query.
Here is what I am doing.
I call a query to get a table for export:
SELECT NewProducts.CategoryL, NewProducts.CategoryS, NewProducts.Keiban, NewProducts.Shouhinmei, NewProducts.ShouhinGazouURL, NewProducts.MobileShopGazouSakusei, NewProducts.OtherGazou1URL, NewProducts.OtherGazou2URL, NewProducts.OtherGazou3URL, NewProducts.HanbaiKakaku, NewProducts.KaiinKakaku, NewProducts.Teika, NewProducts.Genka, NewProducts.Zaikosuu, NewProducts.ZaikoKanri, NewProducts.MinKounyuSuryou, NewProducts.MaxKounyuSuryou, DateValue(NewProducts.StartSaleDate) AS Expr1, TimeValue(NewProducts.StartSaleTime), DateValue(NewProducts.EndSaleDate), TimeValue(NewProducts.EndSaleTime), NewProducts.Unit, NewProducts.Weight, NewProducts.OutofStockHyouji, NewProducts.TekiseiStock, NewProducts.HyoujiJun, NewProducts.KantanDesc, NewProducts.Description, NewProducts.MobileShopDesc, NewProducts.SmartPhoneDesc, NewProducts.TrackBackSettei, NewProducts.NewMarkSettei, NewProducts.NewMarkGazou, NewProducts.CalamelCategoryID, NewProducts.CaramelWord1, NewProducts.CaramelWord2, NewProducts.CaramelWord3, NewProducts.CaramelDesc, NewProducts.Title, NewProducts.Keyword, NewProducts.PageDesc, NewProducts.Shipping, NewProducts.Show INTO ForExport
FROM NewProducts;

Then I use TranserText to export it (please see attached)

Please give me a little more guidance?

Thank you,
EE1.jpg
0
 
LVL 33

Expert Comment

by:Norie
ID: 39160081
Change ForExport to the name of the query based on that table.
0
 

Author Comment

by:yballan
ID: 39160115
in the macro?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39160457
If you just export the table, what does the datetime value look like?
0
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 250 total points
ID: 39160473
There is no need to create a table for this.
Modify your query to a normal select query which you export as you previosly did with the table:

SELECT
  NewProducts.CategoryL,
  NewProducts.CategoryS,
  NewProducts.Keiban,
  NewProducts.Shouhinmei,
  NewProducts.ShouhinGazouURL,
  NewProducts.MobileShopGazouSakusei,
  NewProducts.OtherGazou1URL,
  NewProducts.OtherGazou2URL,
  NewProducts.OtherGazou3URL,
  NewProducts.HanbaiKakaku,
  NewProducts.KaiinKakaku,
  NewProducts.Teika,
  NewProducts.Genka,
  NewProducts.Zaikosuu,
  NewProducts.ZaikoKanri,
  NewProducts.MinKounyuSuryou,
  NewProducts.MaxKounyuSuryou,
  Format(NewProducts.StartSaleDate, "m\/d\/yyyy") AS SSDate,
  Format(NewProducts.StartSaleTime, "hh\:nn") As SSTime,
  Format(NewProducts.EndSaleDate, "m\/d\/yyyy") As ESDate,
  Format(NewProducts.EndSaleTime, "hh\:nn") As ESTime,
  NewProducts.Unit,
  NewProducts.Weight,
  NewProducts.OutofStockHyouji,
  NewProducts.TekiseiStock,
  NewProducts.HyoujiJun,
  NewProducts.KantanDesc,
  NewProducts.Description,
  NewProducts.MobileShopDesc,
  NewProducts.SmartPhoneDesc,
  NewProducts.TrackBackSettei,
  NewProducts.NewMarkSettei,
  NewProducts.NewMarkGazou,
  NewProducts.CalamelCategoryID,
  NewProducts.CaramelWord1,
  NewProducts.CaramelWord2,
  NewProducts.CaramelWord3,
  NewProducts.CaramelDesc,
  NewProducts.Title,
  NewProducts.Keyword,
  NewProducts.PageDesc,
  NewProducts.Shipping,
  NewProducts.Show
FROM
  NewProducts;

/gustav
0
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 250 total points
ID: 39161002
The might be one reason for needing the data to go into a table. An export from a query, can truncate memo fields if the data exceeds 256 characters. If any of you fields have this limit, you may have to write the data into a table and export the table. Fields such as NewProduct.Description need to be checked. If ANY fields that supply data to the table are Memo, look at the expected length of the actual data.


Kelvin
0
 

Author Closing Comment

by:yballan
ID: 39161053
Dear Gustav and Kelvin,

Thank you for detailed explanation, now I understand, and it worked perfectly!!!

yballan
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 39161067
You are welcome!

/gustav
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Access creating a Chart from Search result on Form view 2 21
Run Time Error 3075 15 41
Create Form using Wizard 14 31
MS Access Calculation wont work 5 35
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now