1

Good morning,

I'm currently working on a custom date for a label. It needs to read the last 2 numbers of the current year, followed by the number of day it is within the current year (8/3/2016 would be day 216). So if I were to print a label, the date on 8/3/2016 should read 16216. The following is the current code in the formula:

toText(CurrentDate,"yy") & DateDiff ("d", #1/1#, today) + 1

For reasons I'm unfamiliar with, this returns 16216.00. My question is how do I get rid of the decimal places with this being a text field?

If taken by themselves, toText(CurrentDate,"yy" returns 16 and DateDiff ("d", #1/1#, today) + 1 does return 216. It's only when concatenated that the decimal places appear. Is there a better way to do this?

I'm fairly new to using Crystal, so any help would be appreciated.

Thanks, guys.

Vini.g.fer
  • 11,639
  • 16
  • 61
  • 90
PCGKyle
  • 11
  • 1

1 Answers1

0

You are looking for the Julian date. You have a couple of options

SELECT DATEPART(yy, @date), DATEPART(dy, @date)

SELECT RIGHT(CAST(DATEPART(yy, @date) AS char(4)),2)

The link below goes into much further detail

http://blogs.msmvps.com/robfarley/2009/03/25/converting-to-and-from-julian-format-in-t-sql/

Ramon G
  • 1
  • 1