Solved

Microsoft Query - Microsoft Word Mail Merge

Posted on 2013-06-30
1
472 Views
Last Modified: 2013-08-15
I am running the following query in microsoft word
SELECT DR_TRANS.BRANCHNO, DR_TRANS.TRANSTYPE, DR_ACCS.NAME, DR_ACCS.ADDRESS1, DR_ACCS.ADDRESS2, DR_ACCS.ADDRESS3, DR_ACCS.ADDRESS4, DR_ACCS.POST_CODE, JOBCOST_HDR.SERIALNO, DR_TRANS.TRANSDATE, DR_TRANS.TRANSDATE+14 AS 'DR_TRANS.TRANSDATE14', DR_TRANS.TRANSDATE+21 AS 'DR_TRANS.TRANSDATE21', DR_TRANS.AMOUNT-DR_TRANS.ALLOCATEDBAL AS 'TRANBALANCE', DR_TRANS.AMOUNT, DR_TRANS.ALLOCATEDBAL, DR_ACCS.ACCNO, DR_TRANS.INVNO, DR_TRANS.JOBNO, JOBCOST_HDR.JOBCODE, DR_TRANS.AMOUNT-DR_TRANS.ALLOCATEDBAL-368 AS 'DISCOUNTED_BALANCE', DR_INVLINES.STOCKCODE, DR_INVLINES.LINETOTAL_INCTAX
FROM bledisloe_newzealand.dbo.DR_ACCS DR_ACCS, bledisloe_newzealand.dbo.DR_INVLINES DR_INVLINES, bledisloe_newzealand.dbo.DR_TRANS DR_TRANS, bledisloe_newzealand.dbo.JOBCOST_HDR JOBCOST_HDR
WHERE DR_TRANS.ACCNO = DR_ACCS.ACCNO AND JOBCOST_HDR.JOBNO = DR_TRANS.JOBNO AND JOBCOST_HDR.ACCNO = DR_ACCS.ACCNO AND DR_TRANS.INVNO = DR_INVLINES.INVNO AND DR_INVLINES.TRANSDATE = DR_TRANS.TRANSDATE AND ((DR_TRANS.AMOUNT-DR_TRANS.ALLOCATEDBAL>10 And DR_TRANS.AMOUNT-DR_TRANS.ALLOCATEDBAL<229) AND (DR_TRANS.BRANCHNO>812 And DR_TRANS.BRANCHNO<999) AND (DR_TRANS.TRANSTYPE=1) AND (DR_ACCS.BALANCE>10) AND (DR_TRANS.TRANSDATE+14={ts '2013-06-14 00:00:00'}) AND (DR_INVLINES.STOCKCODE='AADM01') OR (DR_TRANS.AMOUNT-DR_TRANS.ALLOCATEDBAL>231) AND (DR_TRANS.BRANCHNO>812 And DR_TRANS.BRANCHNO<999) AND (DR_TRANS.TRANSTYPE=1) AND (DR_ACCS.BALANCE>10) AND (DR_TRANS.TRANSDATE+14={ts '2013-06-14 00:00:00'}) AND (DR_INVLINES.STOCKCODE='AADM01'))
ORDER BY DR_TRANS.BRANCHNO


in the letter when it merges the date format is coming out as


28/06/2013 12:00:00 AM


Invoice No:      9XXXX / XXXX
Ref:            XXXXXXXX



Public Trust
Private Bag XXXX
Auckland 1500
Attn Tania XXXX



Dear Sir / Madam

RE:  FUNERAL ACCOUNT FOR THE LATE
MR ROBERT XXXXXXXX
BALANCE OUTSTANDING: $XXXXXX

You will have recently received the above account showing a reduced amount of $XXXX if payment is made by 5/07/2013 12:00:00 AM.




Note I need to change the date format  from 05/07/2013 12:00:00AM to 05/07/2013,
to 28/06/2013 12:00:00 AM 28/06/2013.

Thanks
0
Comment
Question by:Amanda Walshaw
1 Comment
 
LVL 48

Accepted Solution

by:
PortletPaul earned 500 total points
ID: 39289007
The will give you dd/mm/yyyy format, but I' not sure which column(s) you are using

, convert(varchar, DR_TRANS.TRANSDATE ,103)    
, convert(varchar, DR_TRANS.TRANSDATE + 14 ,103)    
, convert(varchar, DR_TRANS.TRANSDATE + 21 ,103)    

this date format pattern does not display time, just dd/mm/yyyy
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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

803 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