Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Concatenating two date strings

Hello, I need to perform an update where I set the value to something like this:
dateone ~ datetwo
or
12/12/2008 ~ 12/14/2008

I'm converting the datetime into varchar and then attempting to concatenate the values and finely perform the update.
This is what I have but am getting the following error:

Msg 157, Level 15, State 1, Line 1
An aggregate may not appear in the set list of an UPDATE statement.


My statement:

Update R
set Date = (Select CONVERT(varchar(10),MIN(PR.[Date]),101) + '~' + CONVERT(varchar(10),MAX(PR.[Date]),101) )
from LMVR_PropertyReservations PR
INNER JOIN #Reservations R
ON R.Propertyid = PR.Propertyid
0
gogetsome
Asked:
gogetsome
  • 2
  • 2
1 Solution
 
chapmandewCommented:
try this:

Update R
set Date = (CONVERT(varchar(10),MIN(PR.[Date]),101) + '~' + CONVERT(varchar(10),MAX(PR.[Date]),101) )
from LMVR_PropertyReservations PR
INNER JOIN #Reservations R
ON R.Propertyid = PR.Propertyid
0
 
gogetsomeAuthor Commented:
same error
0
 
chapmandewCommented:
sorry..I missed that.


Update R
set Date = (CONVERT(varchar(10),b.mindate,101) + '~' + CONVERT(varchar(10),b.maxdate,101) )
from LMVR_PropertyReservations PR
INNER JOIN #Reservations R ON R.Propertyid = PR.Propertyid
JOIN
(
select propertyid, min(date) as mindate, max(date) as maxdate
from LMVR_PropertyReservations
group by propertyid
) B  ON b.Propertyid = PR.Propertyid
0
 
gogetsomeAuthor Commented:
Awesome! thank you
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now