trim function with date inserted

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I combined several fields with name and date using trim function, like so
=Trim([Patient name] & " " & [Medical Record] & " " & [Date])
my date defaulting to mm/dd/yyyy. I would like to use the whole line as a
name for word file (exported through report), but word does not accept
mm/dd/yyyy format. How can I reformat date to be acceptable for word file
name. I search for solutions, but did not find a working one.
Thanks
 
Remove the / From the date

=Trim([Patient name] & " " & [Medical Record] & " " &
format([Date],"mmddyyyy"))
 
Hi, Alexasha.

Str(Month(Now()) & Day(Now()) & Year(Now())) will return a string consisting
of today's date:

7182005

If you prefer, you can take the last two digits of the year with the Mid
function:

Mid(Year(Now()),3,2)

returns:

05

If you want the date to be a constant length, padding values less than of
the day and month with a leading zero, write a short custom function:

Function PadZero(intSource As Integer) As String
If intSource < 10 Then
PadZero = "0" & Trim(str(intSource))
Else
PadZero = Trim(str(intSource))
End If
End Function

Then the whole string would be:

PadZero(Month(Now()) & PadZero(Day(Now())) & Mid(Year(Now()),3,2

to return:

071805

Hope that helps.
 
Thanks, Ofer. That certainly is much easier!

Sprinks

Ofer said:
Remove the / From the date

=Trim([Patient name] & " " & [Medical Record] & " " &
format([Date],"mmddyyyy"))

alexasha said:
Hi,
I combined several fields with name and date using trim function, like so
=Trim([Patient name] & " " & [Medical Record] & " " & [Date])
my date defaulting to mm/dd/yyyy. I would like to use the whole line as a
name for word file (exported through report), but word does not accept
mm/dd/yyyy format. How can I reformat date to be acceptable for word file
name. I search for solutions, but did not find a working one.
Thanks
 
thanks ofer. That worked perfect.

Ofer said:
Remove the / From the date

=Trim([Patient name] & " " & [Medical Record] & " " &
format([Date],"mmddyyyy"))

alexasha said:
Hi,
I combined several fields with name and date using trim function, like so
=Trim([Patient name] & " " & [Medical Record] & " " & [Date])
my date defaulting to mm/dd/yyyy. I would like to use the whole line as a
name for word file (exported through report), but word does not accept
mm/dd/yyyy format. How can I reformat date to be acceptable for word file
name. I search for solutions, but did not find a working one.
Thanks
 
Back
Top